package net.maku.module.staff.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.staff.convert.CertificateConvert;
import net.maku.module.staff.entity.CertificateEntity;
import net.maku.module.staff.service.CertificateService;
import net.maku.module.staff.vo.CertificateVO;
import net.maku.newbase.NewBaseController;
import net.maku.newbase.NewQuery;
import net.maku.newbase.PageParam;

import org.springframework.web.bind.annotation.*;

/**
 * 业务_员工_证书
 *
 * @author
 */
@RestController
@RequestMapping("/nb/staff/certificate")
@Tag(name = "业务_员工_证书")
@AllArgsConstructor
public class CertificateController extends NewBaseController<CertificateService, CertificateEntity> {

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<CertificateVO>> page(PageParam page, NewQuery query) {
        LambdaQueryWrapper<CertificateEntity> select = new LambdaQueryWrapper<>();

        IPage<CertificateEntity> iPage = entityService.page(page.b(), select);
        return Result.ok(new PageResult<>(CertificateConvert.INSTANCE.convertList(iPage.getRecords()), iPage.getTotal()));
    }

}